# Maintainer:
# Contributor: Filipe Laíns (FFY00) <lains@archlinux.org>

_name=pony
pkgname=python-$_name
pkgver=0.7.16
pkgrel=3
pkgdesc='Pony Object Relational Mapper'
arch=(any)
url=https://github.com/ponyorm/pony
license=(Apache)
depends=(python)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools
  python-wheel
)
source=(
  $pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz
  $pkgname-0.7.16-python3.11.patch  # https://github.com/ponyorm/pony/pull/671
)
sha512sums=('db9bb06f0e718866eb6f137d5650a2b484119c42f1ade83a7bc1c9e3c27a852ed25e451a226a80bebd050ca3217c0993e59f3b66719a3fe41a98e45349172495'
            '14eb822edd686c0ad425c56d0509f6d43dd954b567f7367b520eda8f05a44ac48c5fb31af01240d6c4f990e2d44ec8402eae774cc2a9f54b00e521711aedbd4a')
b2sums=('bee6447116f215cd586e69f29fea37ba3f9953d0a72b28acf612da2d6e1be07e424b704593e42ae1755e898580aaf4f2e61923ff81e6e58fe0cc8ec04a3b8399'
        'e9ac0d40fd7866db569acf02ed92b914adc6536b8a377016ca1afa0b7aca6c768d8830fb395b28d4b582f358f17aa261fd13058eb7ba6037bca78f91dcc1b134')

prepare() {
  patch -Np1 -d $_name-$pkgver -i ../$pkgname-0.7.16-python3.11.patch
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  python -m unittest discover -vs pony/orm/tests
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  rm -rf "$pkgdir"/usr/lib/python*/site-packages/pony/orm/tests
}
